#include <linux/init.h>
#include <linux/module.h>
#include <linux/irqreturn.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/interrupt.h>

/*
	mykeys{
		interrupt-parent = <&gpiof>;
		interrupts = <9 0>,<7 0>, <8 0>; 
	};
 */

MODULE_LICENSE("GPL");

irqreturn_t btn_irqHandler(int irq, void* dev)
{
    printk("key1 is pressed\n");
    return IRQ_HANDLED;
}

static unsigned int irq;

static int __init btn_drv_init(void)
{
    struct device_node* ledDevNode;
    int ret;
    char buf[30];
    ledDevNode = of_find_node_by_path("/mykeys");
    irq = irq_of_parse_and_map(ledDevNode, 0);

    ret = request_irq(irq,btn_irqHandler,IRQF_TRIGGER_FALLING,"key1",NULL);
    if(ret < 0)
    {
        sprintf(buf,"request_irq %d is failed\n",irq);
        printk(buf);
        return ret;
    }
    return 0;
}

static void __exit btn_drv_exit(void)
{
    free_irq(irq,NULL);
}

module_init(btn_drv_init);
module_exit(btn_drv_exit);

